package com.tsinghua.server.common.utils;


/**
 * 数组工具类
 */

public class ArrayUtil extends cn.hutool.core.util.ArrayUtil {

    /**
     * <p>将fromArray中得数据压入到targetArray数组中</p>
     *
     * @param fromArray
     * @param targetArray
     */
    public static <T> void putToTargetArray(T[] fromArray, T[] targetArray) {
        if (isEmpty(fromArray) || isEmpty(targetArray)) {
            return;
        }
        for (int i = 0; i < targetArray.length; ++i) {
            targetArray[i] = fromArray[i];
        }
    }

    /**
     * 获取class数组的字符串格式
     *
     * @param classArray
     * @return
     */
    public static String getClassArrayStr(Class<?>[] classArray) {
        if (ArrayUtil.isEmpty(classArray)) {
            return null;
        }
        StringBuilder sb = StringUtil.newStringBuilder();
        sb.append("[");
        for (int i = 0; i < classArray.length; ++i) {
            sb.append(classArray[i].getName());
            if (i != classArray.length - 1) {
                sb.append(",");
            }
        }
        sb.append("]");
        return sb.toString();
    }
}
